<script>
	
	function cancel(){
		window.close();
	}
	function save(){
		$("#frmData").attr("action","index.php?r=akademik/pendaftaran_kelas/kelas_tahun_ajaran/edit");
		$("#frmData").attr("target","_self");
		$("#tahun_ajaran_id").removeAttr("disabled");
				
		$("#frmData").submit();		
		$("#tahun_ajaran_id").attr("disabled");
	}
	function karyawanPopupResult(obj){
		console.log(obj);
		$("#wali_kelas_name").val(obj.name);
		$("#wali_kelas_id").val(obj.id);		
	}
	
	function tingkatanOnChange(){
		renewDataKelas();
	}
	function renewDataKelas(){
		var filter = {"is_active":1,"tingkatan_id":$("#tingkatan_id").val()};
		var data ={obj:"MKelas",filter: filter,value_field:"id",title_field:"name"};
		var objTarget = "#kelas_id";
		renewSelectData(data,objTarget);
	}
	
</script>

<div style="border-bottom:2px solid #000;padding-bottom:5px;margin-bottom:20px">
<?php 
	$this->widget('application.components.widgets.ActionBar', 
		array("menuAlign" => "right", 
			'items' => array(
				array(
					'id' => "btnRefresh",
					'title' => "Simpan",
					'icon' => "images/action/Actions-document-save-all-icon.png",
					'callback'=>"save"
				),					
				array(
					'id' => "btnCancel",
					'title' => "Batal",
					'icon' => "images/action/Actions-dialog-cancel-icon.png",
					'callback'=>"cancel"
				),
			)
		)
	);
?>
</div>

<form id="frmData" action="index.php?r=akademik/pendaftaran_kelas/kelas_tahun_ajaran/edit" method="POST">	
	<input type="hidden" name="op" value="<?php echo $op ?>" readonly/>
	<input type="hidden" name="id" id="id" value="<?php echo $id ?>" readonly/>
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label","Departemen")?></label>
		<input class="disabled" type="text" id="department_id" name="department_id" value="<?php echo $department_id ?>" style="width:50px" readonly />		 
	</div>
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label","Tahun Ajaran")?></label>
		<select id="tahun_ajaran_id" name="tahun_ajaran_id" style="width:200px" disabled>
			<?php			
				foreach ($tahunAjarans as $tahunAjaran){
					$selected = $tahunAjaran["id"] == $tahun_ajaran_id ? "selected" : "";
					echo "<option value='$tahunAjaran[id]' $selected>$tahunAjaran[name]</option>";
				}  
			?>
		</select>
	</div>
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label","Tingkatan")?></label>
		<select id="tingkatan_id" name="tingkatan_id" style="width:200px" onchange="tingkatanOnChange()">
			<?php
				foreach ($arrTingkatan as $tingkatan){
					$selected = $tingkatan["id"] == $tingkatan_id ? "selected" : "";
					echo "<option value='$tingkatan[id]' $selected>$tingkatan[name]</option>";
				}  
			?>
		</select>
	</div>
	
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label","Kelas")?></label>
		<select id="kelas_id" name="kelas_id" style="width:200px">
			<?php
				foreach ($arrKelas as $kelas){
					$selected = $kelas["id"] == $kelas_id ? "selected" : "";
					echo "<option value='$kelas[id]' $selected>$kelas[name]</option>";
				}  
			?>
		</select>
	</div>
	<div>
		<label class="form mandatory" style="width:100px"><?php echo Yii::t("label","Biaya bulanan")?></label>
		<input class="currency" type="text" id="monthly_fee" name="monthly_fee" value='<?php echo Yii::app()->numberFormatter->format("##,##0",$monthly_fee) ?>'/>		
	</div>
	
	<div>
	    <?php 
			echo "<label class='form mandatory' style='width:100px;'>".Yii::t("label","Wali kelas") ."</label>";
			$this->widget('application.components.widgets.FindTextField', 
				array('options' => array('id'=>'wali_kelas_name','value'=>$wali_kelas_name),
					'windowParams' => array('url'=>"index.php?r=data_popup/pengajar",'name' => 'popup_target', 
						'specs'=> array('height'=>500,'width'=>500), 
					),
					'callback'=>"karyawanPopupResult",
					'formId'=>'frmData',
				)
			);			
	    ?>		
	    <input type="hidden" id="wali_kelas_id" name="wali_kelas_id" value="<?php echo $wali_kelas_id ?>"  />
	    
	</div>
	
	<div><label class="form" style="width:100px"><?php echo Yii::t("label","status") ?></label><input type="checkbox"  id="is_active" name="is_active" <?php echo $is_active == true?"checked":"" ?> /></div>
	
</form>

